package com.ruixin.mvc.config;

import com.ruixin.base.factory.Factory;

import java.util.List;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.ArrayList;

/**
 * RequestMapping实体对象
 */
public class MethodMapping {

    private String[] paths;

    private RequestType[] requestTypes;

    private boolean jsonResult;

    private Method method;

    private Factory<Parameter,ParameterMapping> argMappingFactory = new Factory<>();

    private List<Parameter> requestBodys = new ArrayList<>();

    public MethodMapping(String[] paths, RequestType[] requestTypes, boolean jsonResult, Method method) {
        this.paths = paths;
        this.requestTypes = requestTypes;
        this.jsonResult = jsonResult;
        this.method = method;
    }

    public String[] getPaths() {
        return paths;
    }

    public void setPaths(String[] paths) {
        this.paths = paths;
    }

    public RequestType[] getRequestTypes() {
        return requestTypes;
    }

    public void setRequestTypes(RequestType[] requestTypes) {
        this.requestTypes = requestTypes;
    }

    public boolean isJsonResult() {
        return jsonResult;
    }

    public void setJsonResult(boolean jsonResult) {
        this.jsonResult = jsonResult;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }


    public Factory<Parameter, ParameterMapping> getArgMappingFactory() {
        return argMappingFactory;
    }

    public void setArgMappingFactory(Factory<Parameter, ParameterMapping> argMappingFactory) {
        this.argMappingFactory = argMappingFactory;
    }

    public void setArgMapping(Parameter parameter,ParameterMapping argMapping){
        this.argMappingFactory.put(parameter,argMapping);
    }

    public List<Parameter> getRequestBodys() {
        return requestBodys;
    }

    public void setRequestBodys(List<Parameter> requestBodys) {
        this.requestBodys = requestBodys;
    }

    public void setRequestBody(Parameter parameter){
        this.requestBodys.add(parameter);
    }
}
